<template>
	<view>
		<!-- 头部导航栏 -->
		
		<uni-nav-bar  :border="false" 
		  :fixed="true" :statusBar="true"
		  left-icon="left"
		  left-width="28rpx"
		  @clickLeft="navBack"
		   >
		   <view class="record_title">浏览记录</view>
		</uni-nav-bar>
		<view class="flex_row_start_center record_list" 
		      v-for="(item,index) in list" 
			  :key="index"
			  @click="navto(item)"
			  >
			<view>
				<image v-if="item.picture" :src="item.picture.split(',')[0]" mode="aspectFill" class="record_image"></image>
			</view>
			<view class="record_list_r">
				<view class="record_list_r_title">{{item.title ? item.title:item.content}}</view>
				<view class="flex_row_between_center">
					<view>{{item.member.memberNickName}}</view>
					<view>{{$changeTime(item.createTime)}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				list:[],
				current:1,
			}
		},
		onLoad(){
			this.getRecord()
		},
		methods:{
			getRecord(){
				
				let param = {};
				param.url = 'v3/brow/front/history/list';
				param.data = {};
				param.data.pageSize = 10;
				param.data.current = this.current;
				
				this.$request(param).then(res => {
					// console.log('resss',res);
					this.list=this.list.concat(res.data.list);
					console.log('this.list',this.list);
					let hasMore = this.$checkPaginationHasMore(res.data.pagination); //是否还有数据
					if (hasMore) {
						this.current++;
						// navItem.loadingState = 'allow_loading_more';
					} else {
						// navItem.loadingState = 'no_more_data';
					}
					
				}).catch((e) => {
					//异常处理
				})
			},
			navto(item){
				let url="/pages/index/reportdetail"
				const obj = {
					id:item.discussPostId
				}
				console.log('obj',obj);
				
				// 将对象参数转为JSON字符串，并使用encodeURIComponent编码
				const params = encodeURIComponent(JSON.stringify(obj));
				
				// 跳转页面并传递对象参数
				uni.navigateTo({
				   url: `${url}?params=${params}`
				});
			},
			navBack(){
				this.$tab.navigateBack()
			},
		}
	}
</script>

<style>
	page{
		background-color: #f7f7f7;
	}
</style>
<style lang="scss" scoped>
	
	.record_title{
		font-size: 28rpx;
		// background-color: red;
		display: flex;
		align-items: center;
	}
	.record_list{
		padding: 20rpx 16rpx;
		margin-bottom: 14rpx;
		background-color: #fff;
	}
	.record_image{
		width: 140rpx;
		height: 140rpx;
		border-radius: 30rpx;
		margin-right: 24rpx;
	}
	.record_list_r{
		flex: 1;
	}
	.record_list_r_title{
		margin-bottom: 24rpx;
		word-break: break-all; // 允许单词内自动换行，如果一个单词很长的话
		text-overflow: ellipsis; // 溢出用省略号显示
		overflow: hidden; // 超出的文本隐藏
		display: -webkit-box; // 作为弹性伸缩盒子模型显示
		-webkit-line-clamp: 2; // 显示的行
		-webkit-box-orient: vertical; // 设置伸缩盒子的子元素排列方式--从上
	}
</style>